<!doctype html>
<html lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8">
    <meta name="baidu-site-verification" content="dIcXMeY8Ya">
    
    <title>Effective Java part5 | blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="keywords" content="Jim, 服务端, Java, Java开发">
    <meta name="description" content="Jim个人学习记录">

    
    <link rel="alternative" href="/atom.xml" title="blog" type="application/atom+xml">
    
    
    <link rel="shortcut icon" href="/favicon.ico">
    
    <link rel="stylesheet" href="/css/style.css">
    <!--[if lt IE 9]>
    <script src="/js/html5.js"></script>
    <![endif]-->
    
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?fd459238242776d173cdc64918fb32f2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</head>
</html>
<body class="home">
    <!--[if lt IE 9]>
    <div class="browsehappy">
        当前网页 <strong>不支持</strong>
        你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.
    </div>
    <![endif]-->

    <!-- 博客头部 -->
    <header class="header">
    <section class="container header-main">
        <div class="logo">
            <a href="/">
                <div class="cover">
                    <span class="name">blog</span>
                    <span class="description"></span>
                </div>
            </a>
        </div>
        <div class="dropnav icon-paragraph-justify" id="JELON__btnDropNav"></div>
        <ul class="menu hidden" id="JELON__menu">
            
            <li rel="/2020/01/26/part5-重写equals遵守约定/index.html" class="item ">
                <a href="/" title="首页" class="icon-home">&nbsp;首页</a>
            </li>
            
            <li rel="/2020/01/26/part5-重写equals遵守约定/index.html" class="item ">
                <a href="/about/" title="关于" class="icon-about">&nbsp;关于</a>
            </li>
            
            <li rel="/2020/01/26/part5-重写equals遵守约定/index.html" class="item ">
                <a href="/comment/" title="留言" class="icon-comment">&nbsp;留言</a>
            </li>
            
        </ul>
        <div class="profile clearfix">
            <div class="feeds fl">
                
                
                <p class="links">
                    
                        <a href="https://github.com/starryming" target="_blank">Github</a>
                        |
                    
                        <a href="http://ljmstarry.gitee.io" target="_blank">Hosted by Coding Pages</a>
                        
                    
                </p>
                <p class="sns">
                    
                        <a href="http://weibo.com/" class="sinaweibo" target="_blank"><b>■</b> 新浪微博</a>
                    
                        <a href="https://www.facebook.com/" class="qqweibo" target="_blank"><b>■</b> Facebook</a>
                    
                    <a href="javascript: void(0);" class="wechat">
                        <b>■</b>
                        公众号
                        <span class="popover">
                            <img src="/img/wechat_mp.jpg" width="120" height="120" alt="我的微信订阅号">
                            <i class="arrow"></i>
                        </span>
                    </a>
                </p>
                
            </div>
            <div class="avatar fr">
                <img src="/img/timg.jpg" alt="avatar" title="Jim">
            </div>
        </div>
    </section>
</header>


    <!-- 博客正文 -->
    <div class="container body clearfix">
        <section class="content">
            <div class="content-main widget">
                <!-- 文章页 -->
<!-- 文章 -->
<article class="post article">
    <header class="text-center">
        <h3 class="post-title"><span>Effective Java part5</span></h3>
    </header>
    <p class="post-meta text-center">
        Jim 发表于
        <time datetime="2020-01-26T07:22:59.000Z">2020-01-26</time>
    </p>
    <div class="post-content">
        <h3 id="重写equals遵守约定"><a href="#重写equals遵守约定" class="headerlink" title="重写equals遵守约定"></a>重写equals遵守约定</h3><blockquote>
<p>如果一个类包含一个逻辑相等（logical equality）的概念，此概念有别于对象标识（object identity）即对象标识无法满足区分，而且父类还没有重写过 equals 方法，此时我们需要重写equals方法。</p>
</blockquote>
<a id="more"></a>
<p>[TOC]</p>
<h4 id="一、简述"><a href="#一、简述" class="headerlink" title="一、简述"></a>一、简述</h4><p><strong>什么时候需要重写 equals 方法呢？</strong></p>
<p>如果一个类包含一个逻辑相等（logical equality）的概念，此概念有别于对象标识（object identity）即对象标识无法满足区分，而且父类还没有重写过 equals 方法，此时我们需要重写equals方法。</p>
<blockquote>
<p>这通常用在值类（value classes）的情况。值类只是一个表示值的类，例如 Integer 或 String 类。程序员使用 equals 方法比较值对象的引用，期望发现它们在逻辑上是否相等，而不是引用相同的对象。重写 equals 方法不仅可以满足程序员的期望，它还支持重写过 equals 的实例作为 Map 的键（key），或者 Set 里的元素，以满足预期和期望的行为。</p>
</blockquote>
<p><strong>例</strong>：类中存放了验证码信息，我们希望判断相等的时候不区分大小写。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object o)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> o <span class="keyword">instanceof</span> CaseInsensitiveString</span><br><span class="line">            &amp;&amp; ((CaseInsensitiveString) o).s.equalsIgnoreCase(s);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="二、准则"><a href="#二、准则" class="headerlink" title="二、准则"></a>二、准则</h4><h5 id="1、通用约定"><a href="#1、通用约定" class="headerlink" title="1、通用约定"></a>1、通用约定</h5><p>重写 equals 方法时，必须遵守它的通用约定。<br>Object 的规范如下：equals 方法实现了一个等价关系（equivalence relation）</p>
<ul>
<li><strong>自反性：</strong> 对于任何非空引用 x，<code>x.equals(x)</code> 必须返回 true。</li>
<li><strong>对称性：</strong> 对于任何非空引用 x 和 y，如果且仅当 <code>y.equals(x)</code> 返回 true 时 <code>x.equals(y)</code> 必须返回 true。</li>
<li><strong>传递性：</strong> 对于任何非空引用 x、y、z，如果 <code>x.equals(y)</code> 返回 true，<code>y.equals(z)</code> 返回 true，则 <code>x.equals(z)</code> 必须返回 true。</li>
<li><strong>一致性：</strong> 对于任何非空引用 x 和 y，如果在 equals 比较中使用的信息没有修改，则 <code>x.equals(y)</code> 的多次调用必须始终返回 true 或始终返回 false。</li>
<li>对于任何非空引用 x，<code>x.equals(null)</code> 必须返回 false。</li>
</ul>
<h5 id="2、约定案例实践"><a href="#2、约定案例实践" class="headerlink" title="2、约定案例实践"></a>2、约定案例实践</h5><h6 id="自反性"><a href="#自反性" class="headerlink" title="自反性"></a>自反性</h6><h6 id="对称性"><a href="#对称性" class="headerlink" title="对称性"></a>对称性</h6><p> <code>y.equals(x)</code> 返回 true 时 <code>x.equals(y)</code> 必须返回 true</p>
<h6 id="传递性"><a href="#传递性" class="headerlink" title="传递性"></a>传递性</h6><p><code>x.equals(y)</code> 返回 true，<code>y.equals(z)</code> 返回 true，则 <code>x.equals(z)</code> 必须返回 true</p>
<p><strong>例：</strong></p>
<p>父类Point:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Point</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">int</span> x;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">int</span> y;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Point</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.x = x;</span><br><span class="line">        <span class="keyword">this</span>.y = y;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object o)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (!(o <span class="keyword">instanceof</span> Point)) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        Point p = (Point) o;</span><br><span class="line">        <span class="keyword">return</span> p.x == x &amp;&amp; p.y == y;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>子类ColorPointDemo2使用继承的形式，在对equals重写时，会引传递性丧失：</p>
<blockquote>
<p>p1.equals(p2) 为true</p>
<p>p2.equals(p3) 为true </p>
<p>p1.equals(p3) 为false 而不是true =&gt; 违反了传递性</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ColorPointDemo2</span> <span class="keyword">extends</span> <span class="title">Point</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> Color color;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">ColorPointDemo2</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y, Color color)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">super</span>(x, y);</span><br><span class="line">        <span class="keyword">this</span>.color = color;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Broken - violates symmetry!</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object o)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (!(o <span class="keyword">instanceof</span> Point)) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (!(o <span class="keyword">instanceof</span> ColorPointDemo2)) &#123;</span><br><span class="line">            <span class="keyword">return</span> o.equals(<span class="keyword">this</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">super</span>.equals(o) &amp;&amp; ((ColorPointDemo2) o).color == color;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        ColorPointDemo2 p1 = <span class="keyword">new</span> ColorPointDemo2(<span class="number">1</span>, <span class="number">2</span>, Color.RED);</span><br><span class="line">        Point p2 = <span class="keyword">new</span> Point(<span class="number">1</span>, <span class="number">2</span>);</span><br><span class="line">        ColorPointDemo2 p3 = <span class="keyword">new</span> ColorPointDemo2(<span class="number">1</span>, <span class="number">2</span>, Color.BLUE);</span><br><span class="line"></span><br><span class="line">        System.out.println(p1.equals(p2));</span><br><span class="line">        System.out.println(p2.equals(p3));</span><br><span class="line">        <span class="comment">// 违反传递性</span></span><br><span class="line">        System.out.println(p1.equals(p3));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>因此，借助“优先使用组合而不是继承”，我们可以通过组合的形式，来提供出一份解决方案：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ColorPointDemo3</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> Color color;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> Point point;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">ColorPointDemo3</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y, Color color)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.color = Objects.requireNonNull(color);</span><br><span class="line">        <span class="keyword">this</span>.point = <span class="keyword">new</span> Point(x,y);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object o)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (!(o <span class="keyword">instanceof</span> ColorPointDemo3)) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        ColorPointDemo3 cp = (ColorPointDemo3) o;</span><br><span class="line">        <span class="keyword">return</span> cp.point.equals(point) &amp;&amp; cp.color.equals(color);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h6 id="一致性"><a href="#一致性" class="headerlink" title="一致性"></a>一致性</h6><p>不要写一个依赖于不可靠资源的 equals 方法</p>
<h5 id="3、hashCode通用约定"><a href="#3、hashCode通用约定" class="headerlink" title="3、hashCode通用约定"></a>3、hashCode通用约定</h5><p>重写equals时，一定要重写hashCode</p>

    </div>
    <p class="post-meta">
        <span class="post-cat">分类：
            <a class="cat-link" href="/categories/Reading/">Reading</a>
        </span>
        <span class="post-tags">
            标签：
            
    
        <a href="/tags/阅读/" title="阅读">阅读</a> / 
    
        <a href="/tags/Effective-Java/" title="Effective Java">Effective Java</a>
    

        </span>
    </p>
</article>
<!-- 分享按钮 -->

  <div class="article-share clearfix text-center">
    <div class="share-area">
      <span class="share-txt">分享到：</span>
      <a href="javascript: window.open('http://service.weibo.com/share/share.php?url=' + encodeURIComponent(location.href) + '&title=' + document.title + '&language=zh_cn');" class="share-icon weibo"></a>
      <a href="javascript: alert('请复制链接到微信并发送');" class="share-icon wechat"></a>
      <a href="javascript: window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(location.href) + '&title=' + document.title);" class="share-icon qqzone"></a>
      <a href="javascript: window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location.href) + '&desc=Jim个人博客&title=' + document.title + '&callback=' + encodeURIComponent(location.href));" class="share-icon qq"></a>
      <a href="javascript: window.open('http://shuo.douban.com/!service/share?href=' + encodeURIComponent(location.href) + '&name=' + document.title + '&text=' + document.title);" class="share-icon douban"></a>
    </div>
  </div>


<!-- 上一篇/下一篇 -->

<div class="article-nav clearfix">
    
    <span class="prev fl">
        上一篇<br>
        <a href="/2020/01/27/part6-接口仅用来定义类型/">
            
                Effective Java part6
            
        </a>
    </span>
    

    
    <span class="next fr">
        下一篇<br>
        <a href="/2020/01/24/part4-消出过期的对象引用/">
            
                Effective Java part4
            
        </a>
    </span>
    
</div>

<!-- 文章评论 -->

  <script src="/js/comment.js"></script>
  <div id="comments" class="comment">
    <!--
    <div class="sign-bar">
      GitHub 已登录!
      <span class="sign-link">登出</span>
    </div>
    <section class="box">
      <div class="com-avatar"><img src="/img/jelon.jpg" alt="avatar"></div>
      <div class="com-text">
        <div class="main">
          <textarea class="text-area-edited show" placeholder="欢迎评论！"></textarea>
          <div class="text-area-preview"></div>
        </div>
        <div class="switch">
          <div class="switch-item on">编辑</div>
          <div class="switch-item">预览</div>
        </div>
        <div class="button">提交</div>
      </div>
    </section>
    <section class="tips">注：评论支持 markdown 语法！</section>
    <section class="list-wrap">
      <ul class="list">
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">张德龙</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like liked">已赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">333333</div>
          </div>
        </li>
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">刘德华</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like">点赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">vvvvv</div>
          </div>
        </li>
      </ul>
      <div class="page-nav">
        <a href="javascript: void(0);" class="item">1</a>
        <a href="javascript: void(0);" class="item">2</a>
        <a href="javascript: void(0);" class="item current">3</a>
      </div>
    </section>
    -->
  </div>
  <script>
  JELON.Comment({
    container: 'comments',
    label: 'part5-重写equals遵守约定' || '2020/01/26/part5-重写equals遵守约定/',
    owner: 'your_github_id',
    repo: 'your_blog_comments',
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret'
  });
  </script>


            </div>

        </section>
        <!-- 侧栏部分 -->
<aside class="sidebar">
    <section class="widget">
        <h3 class="widget-hd"><strong>文章分类</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
    <li>
        <a href="/categories/linus/">linus</a>
        <span class="badge">(4)</span>
    </li>
    
    <li>
        <a href="/categories/technology/">technology</a>
        <span class="badge">(8)</span>
    </li>
    
    <li>
        <a href="/categories/Reading/">Reading</a>
        <span class="badge">(13)</span>
    </li>
    
    <li>
        <a href="/categories/others/">others</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/linus/technology/">technology</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/mysql/">mysql</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/mysql/technology/">technology</a>
        <span class="badge">(1)</span>
    </li>
    
</ul>
    </section>

    
    <section class="widget">
        <h3 class="widget-hd"><strong>热门标签</strong></h3>
        <!-- 文章标签 -->
<div class="widget-bd tag-wrap">
  
    <a class="tag-item" href="/tags/linus/" title="linus">linus (4)</a>
  
    <a class="tag-item" href="/tags/ngnix/" title="ngnix">ngnix (1)</a>
  
    <a class="tag-item" href="/tags/源码学习/" title="源码学习">源码学习 (2)</a>
  
    <a class="tag-item" href="/tags/阅读/" title="阅读">阅读 (13)</a>
  
    <a class="tag-item" href="/tags/Thinking-In-Java/" title="Thinking In Java">Thinking In Java (5)</a>
  
    <a class="tag-item" href="/tags/java/" title="java">java (3)</a>
  
    <a class="tag-item" href="/tags/technology/" title="technology">technology (1)</a>
  
    <a class="tag-item" href="/tags/springBoot/" title="springBoot">springBoot (2)</a>
  
    <a class="tag-item" href="/tags/设计模式/" title="设计模式">设计模式 (3)</a>
  
    <a class="tag-item" href="/tags/test/" title="test">test (1)</a>
  
    <a class="tag-item" href="/tags/Effective-Java/" title="Effective Java">Effective Java (8)</a>
  
    <a class="tag-item" href="/tags/mysql/" title="mysql">mysql (2)</a>
  
    <a class="tag-item" href="/tags/Docker/" title="Docker">Docker (1)</a>
  
</div>
    </section>
    

    

    
    <!-- 友情链接 -->
    <section class="widget">
        <h3 class="widget-hd"><strong>友情链接</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
        <li>
            <a href="https://www.bilibili.com" target="_blank" title="bilibili">哔哩哔哩</a>
        </li>
    
        <li>
            <a href="https://www.baidu.com" target="_blank" title="百度搜索">百度</a>
        </li>
    
</ul>
    </section>
    
</aside>
<!-- / 侧栏部分 -->
    </div>

    <!-- 博客底部 -->
    <footer class="footer">
    &copy;
    
        2016-2020
    

    <a href="/">Jim Loves You</a>
</footer>
<div class="back-to-top" id="JELON__backToTop" title="返回顶部">返回顶部</div>

    <!--博客js脚本 -->
    <!-- 这里放网站js脚本 -->
<script src="/js/main.js"></script>
</body>
</html>